#include"process.h"
#include<string.h>
#include<unistd.h>

#define SIZE 101
#define TYTLE '#'

void process1()
{
    char str[SIZE];
    memset(str,0,sizeof(str));
    const char* t="|/-\\";
    int sum=0;
    int size=strlen(t);
    while(sum<=100)
    {
        printf("[%-100s][%d%%][%c]\r",str,sum,t[sum%size]);
        str[sum]=TYTLE;
        sum++;
        fflush(stdout);
        usleep(100000);

    }
    printf("\n");



}


void process2(const char* s,double cur,double totle)
{
    char str[SIZE];
    const char* t="/|-\\";
    memset(str,0,sizeof(str));
    int size=strlen(t);
    double rate=cur*100/totle;
    int  num=(int)rate;
    int i=0;
    for(;i<=num;i++)
    {
        str[i]=TYTLE;
    }
    static int x=0;
    x=num%size;
    printf("[%s][%-100s][%.1lf%%][%c]\r",s,str,rate,t[x]);
    x++;
    fflush(stdout);
}
